package pica.ui;

import c;
import java.util.Enumeration;
import java.util.Vector;
import javax.microedition.lcdui.*;

// Referenced classes of package pica.ui:
//            b

public class h extends Canvas
    implements Runnable
{

    public h(Display display)
    {
        setFullScreenMode(true);
        d = display;
        a = new Vector();
        repaint();
        e = getHeight();
        f = getWidth();
        c = System.currentTimeMillis();
        i = true;
    }

    public final void c()
    {
        i = false;
    }

    public static Display d()
    {
        return d;
    }

    public final void a(c c1)
    {
        b = c1;
    }

    public final void a(b b1)
    {
        a.addElement(b1);
    }

    public final void e()
    {
        a.removeAllElements();
    }

    public final b a(String s)
    {
        b b1;
        for(Enumeration enumeration = a.elements(); enumeration.hasMoreElements();)
            if((b1 = (b)enumeration.nextElement()).c != null && b1.c.equals(s))
                return b1;

        return null;
    }

    public final void a(b b1, String s)
    {
        for(int k = 0; k < a.size(); k++)
        {
            b b2;
            if((b2 = (b)a.elementAt(k)).c != null && b2.c.equals(s))
                a.setElementAt(b1, k);
        }

    }

    public final void run()
    {
        for(; i; c = System.currentTimeMillis())
        {
            repaint();
            long l;
            if((l = System.currentTimeMillis() - c) >= 120L)
                continue;
            try
            {
                Thread.sleep(120L - l);
            }
            catch(Exception _ex) { }
        }

    }

    private void a(byte byte0, int k)
    {
        boolean flag = false;
        boolean flag1;
        b b1;
        for(int l = 0; l < a.size() && (!(b1 = (b)a.elementAt(l)).d || !(flag1 = b1.a(byte0, k))); l++);
        if(b != null)
        {
            if(byte0 == 0)
            {
                b.a(0, new Integer(k));
                return;
            }
            if(byte0 == 1)
            {
                b.a(2, new Integer(k));
                return;
            }
            if(byte0 == 2)
                b.a(1, new Integer(k));
        }
    }

    private void a(byte byte0, int k, int l)
    {
        boolean flag = false;
        boolean flag1;
        b b1;
        for(int i1 = 0; i1 < a.size() && (!(b1 = (b)a.elementAt(i1)).d || !(flag1 = b1.a(byte0, k, l))); i1++);
        if(b != null)
        {
            if(byte0 == 1)
            {
                b.a(3, ((Object) (new Object[] {
                    new Integer(k), new Integer(l)
                })));
                return;
            }
            if(byte0 == 0)
            {
                b.a(4, ((Object) (new Object[] {
                    new Integer(k), new Integer(l)
                })));
                return;
            }
            if(byte0 == 2)
                b.a(5, ((Object) (new Object[] {
                    new Integer(k), new Integer(l)
                })));
        }
    }

    protected final void paint(Graphics g1)
    {
        if(!j)
        {
            g1.setColor(0xffff00);
            g1.fillRect(0, 0, f, e);
            j = true;
            f = getWidth();
            e = getHeight();
            return;
        }
        for(int k = a.size() - 1; k >= 0; k--)
            ((b)a.elementAt(k)).a(g1);

        g1.setColor(0xff0000);
    }

    protected final void keyPressed(int k)
    {
        a((byte)0, k);
        repaint();
    }

    protected final void keyReleased(int k)
    {
        a((byte)2, k);
    }

    protected final void keyRepeated(int k)
    {
        a((byte)1, k);
    }

    protected final void pointerDragged(int k, int l)
    {
        a((byte)1, k, l);
        repaint();
    }

    protected final void pointerPressed(int k, int l)
    {
        a((byte)0, k, l);
        repaint();
    }

    protected final void pointerReleased(int k, int l)
    {
        a((byte)2, k, l);
    }

    public static Display d;
    private Vector a;
    private c b;
    private long c;
    private boolean i;
    private boolean j;
    protected int e;
    protected int f;
    public static boolean g = true;
    public static StringBuffer h = new StringBuffer();

}
